/**
 * Project Name:swt-hello <br/>
 * File Name:App.java <br/>
 * Package Name:com.ftu.z <br/>
 */
package com.ftu.swt.basic1;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


/**
 * <p>  </p>
 * @version 1.0 2018年11月22日 mq 修改内容:初版
 */
public class UsingImage {
    public static void main(String[] args) {
        Display display = Display.getDefault();
        
        Shell shell1 = new Shell(display);
        
        shell1.setText("shell1");
        
        shell1.setSize(400, 400);
        
        final Button button = new Button(shell1, SWT.NONE);
        button.setText("Dispose Display");
        shell1.setImage(display.getSystemImage(SWT.ICON_QUESTION));
        button.setBounds(10, 10, 120, 20);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                try {
                    Thread.sleep(5000);
                    button.setText("Execution done");
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
                
            }
        });
        
        shell1.open();
        while(!shell1.isDisposed()) {
            if(!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
        
    }

}
